

//
//  GXXZTableViewCell.m
//  DJS
//
//  Created by mac on 2018/3/15.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GXXZTableViewCell.h"
#import "GXViewController.h"
@implementation GXXZTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(CGFloat)creatView{
    self.backgroundColor=_LightGrey;
    NSArray *typeArr=[_dic objectForKey:@"children"];
    int x=typeArr.count%3;
    int y=typeArr.count/3;
    if (x>0) {
        y+=1;
    }
    
    UIView *view=[UIView new];
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(-5);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(0);
    }];
    view.backgroundColor=[UIColor whiteColor];
    view.layer.cornerRadius=3;
    
    UIView *view2=[UIView new];
    [view addSubview:view2];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];
    
    UILabel*label=[UILabel new];
    [view2 addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
    }];
    label.text=[_dic objectForKey:@"name"];
    label.font=[UIFont systemFontOfSize:15];
    label.textColor=ColorWithRGB(149, 149, 149);
    
    int index=0;
    for (int i=0; i<y; i++) {
        for (int j=0; j<3; j++) {
            UIView *view3=[UIView new];
            [view addSubview:view3];
            [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo((_mainW-20)/3*j);
                make.top.mas_equalTo(40*i+40);
                make.width.mas_equalTo((_mainW-20)/3);
                make.height.mas_equalTo(40);
            }];
            view3.tag=index;
            view3.userInteractionEnabled=YES;
            UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToGengXing:)];
            [view3 addGestureRecognizer:tapGesture2];
            
            
            NSDictionary *typeDic=typeArr[index];
            
            UILabel*label2=[UILabel new];
            [view3 addSubview:label2];
            [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.center.mas_equalTo(0);
            }];
            label2.text=[typeDic objectForKey:@"st_name"];
            label2.font=[UIFont systemFontOfSize:15];
            label2.textColor=ColorWithRGB(149, 149, 149);
         
            if (index==typeArr.count-1) {
                continue ;
            }
            index+=1;
            
            
        }
    }
    
    
    for ( int i=0; i<y; i++) {
        UIView *xianView=[UIView new];
        [view addSubview:xianView];
        [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(1);
            make.top.mas_equalTo(i*40+40);
        }];
        xianView.backgroundColor=_LightGrey;
    }
    
    for ( int i=1; i<3; i++) {
        UIView *xianView=[UIView new];
        [view addSubview:xianView];
        [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo((_mainW-20)/3*i);
            make.width.mas_equalTo(1);
            make.bottom.mas_equalTo(0);
            make.top.mas_equalTo(40);
        }];
        xianView.backgroundColor=_LightGrey;
    }
    
    
    return y*40+55;
    
}

-(void)pushToGengXing:(UITapGestureRecognizer *)tap{
    
    
    NSArray *typeArr=[_dic objectForKey:@"children"];
    NSDictionary *typeDic=typeArr[tap.view.tag];
    GXViewController *gengx=[[GXViewController alloc] init];
    gengx.str=[_dic objectForKey:@"name"];
    gengx.dic=typeDic;
    gengx.litigation_id=_litigation_id;
    [ZQTools pushNextViewController:self.viewController andRootController:gengx];
    
}

@end
